#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>

#include <string>
#include <vector>
using namespace std;

vector<pair<bool, int> > words;

#define MAXL (1000000 + 5)

char buf[MAXL];
int K;

string garbage = " .,:'();[]{}/-";

void PrintVec(vector<int>& vec, string name) {
  printf("%s>>\n", name.c_str());
  for (int i = 0; i < vec.size(); ++i) {
    printf("%d\n", vec[i]);
  }
  puts("");
}

void Parse() {
  int len = strlen(buf);
  int i = 0;
  while (i < len) {
    // Skip garbage.
    while (i < len && !isalpha(buf[i])) {
      ++i;
    }
    if (i >= len) {
      break;
    }

    assert(isalpha(buf[i]));
    string word;
    while (i < len && isalpha(buf[i])) {
      word.push_back(buf[i]);
      ++i;
    }
    if (word == "Alice") {
      words.push_back(make_pair(true, i));
    } else if (word == "Bob") {
      words.push_back(make_pair(false, i));
    }
  }
}

void Solve() {
  int ans = 0;
  // Look for all pairs.
  for (int i = 0; i < words.size() - 1; ++i) {
    pair<bool, int> x, y;
    x = words[i];
    y = words[i + 1];
    if (x.first == y.first) {
      continue;
    }

    int dis = y.second - x.second;
    // assert(dis > 0);

    if (x.first) {
      // x is alice.
      dis -= 3;
    } else {
      dis -= 5;
    }
    if (dis <= K) {
        // printf("%d %d %d %d\n", x.first, x.second,y.first,y.second);
      ans++;
    }
  }
  printf("%d\n", ans);
}

int main() {
  freopen("in.txt", "r", stdin);
  scanf("%d", &K);
  getchar();
  fgets(buf, sizeof(buf), stdin);

  Parse();
  Solve();

  return 0;
}